package mediaServer.logic;

import mediaServer.configurationManagement.Configuration;

public class MediaModule {

	
	VLCManager vlcm = null;
	Configuration _config = null;
	
	public MediaModule (Configuration config){
		_config = config;
		getVLCManager();
	}
	
	public void sendTo(String address) {
		//System.out.println("Address received on MEDIA MANAGER: " +address);
		if ((address.charAt(0)==('['))&&address.charAt(address.length()-1)==(']'))
			address = address.substring(1,address.length()-1);
		String host = address.substring(0,address.indexOf(":"));
		int port = Integer.parseInt(address.substring(address.indexOf(":")+1));
		vlcm.addAddress(host,port);
		vlcm.transmit();
	}
	
	public void sendTo(String address,int port) {
		System.out.println("Address received on MEDIA MANAGER: " +address);
		vlcm.addAddress(address,port);
		vlcm.transmit();
	}

	private VLCManager getVLCManager(){
		if (vlcm == null)
			vlcm = new VLCManager(_config);
		return vlcm;
	}


}
